import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import viteCompression from 'vite-plugin-compression'

const NODE_ENV = process.env.NODE_ENV

let VITE_API_URL = ''
const base = 'https://ainengli.hzjrsw.com/be-eprofile-app'
// #ifndef H5
VITE_API_URL =
  NODE_ENV === 'development'
    ? 'http://192.168.100.50:8107'
    : ''
    // https://ainengli.hzjrsw.com/be-eprofile-app
// #endif
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [uni(), viteCompression()],
  // build: {
  //   minify: 'terser',
  //   terserOptions: {
  //     compress: {
  //       drop_console: true,
  //       drop_debugger: true
  //     }
  //   }
  // },
  define: {
    'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
    'process.env.VITE_API_URL': JSON.stringify(VITE_API_URL)
  },
  // base: '/health-manager-h5',
  server: {
    host: '0.0.0.0',
    port: 5173, // 端口号
    open: false, // 是否自动打开浏览器
    proxy: {
      '^/patient': {
        target: base,
        changeOrigin: true
      },
      '^/api': {
        target: base,
        changeOrigin: true
      }
    }
  }
})
